import { defineConfig, loadEnv } from "vite";
import uni from "@dcloudio/vite-plugin-uni";
// https://vitejs.dev/config/

export default ({mode}) => {
	const envPrefix = "VITE_"
	const ENV = loadEnv(mode, './', envPrefix)
	console.log(ENV.VITE_BASE_URL,'ENV.VITE_BASE_URL',ENV.VITE_PROXY_URL)
	return defineConfig({
		envPrefix,
		transpileDependencies: ['uview-plus'],
		plugins: [uni()],
		server:{
		  host:"0.0.0.0",
		  port:80,
		  open:false,
		  proxy: ENV.VITE_PROXY_URL && {
			[ENV.VITE_PROXY_URL]: {
			  target: ENV.VITE_BASE_URL,
			  changeOrigin: true,
			  rewrite: (path) => path.replace(ENV.VITE_PROXY_URL, ''),
			},
		  }
		}
	})
};
